home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntlib43 / mntlib / clock.c < prev    next >
C/C++ Source or Header  |  1993-09-15  |  814b  |  43 lines

  1. /* _clock -- return process time used so far, in units of CLK_TCK ticks
  2.    per second (under TOS, 200 per second) */
  3. /* written by ERS */
  4.  
  5. #include <time.h>
  6. #include <osbind.h>
  7.  
  8. extern clock_t _starttime; /* in main.c */
  9.  
  10. static clock_t now;
  11.  
  12. /* this must execute in supervisor mode; it fetches the system variable
  13.  * containing the number of 200HZ ticks since the system was booted
  14.  */
  15.  
  16. static long getnow __PROTO((void));
  17.  
  18. static long
  19. getnow()
  20. {
  21.     now = *((unsigned long *) 0x4baL);
  22.     return 0;
  23. }
  24.  
  25. clock_t
  26. _clock()
  27. {
  28.     (void)Supexec(getnow);
  29.     return (now - _starttime);
  30. }
  31.  
  32. /* This next bit of nonsense is temporary...clock() should be fixed! */
  33.  
  34. #ifdef __GNUC__
  35. asm(".stabs \"_clock\",5,0,0,__clock"); /* dept of clean tricks */
  36. #else /* ! __GNUC__ */
  37. clock_t
  38. clock()
  39. {
  40.   return _clock();
  41. }
  42. #endif /* ! __GNUC__ */
  43.